package com.ruanyun.modular.admin.controller;

import com.ruanyun.base.pojo.page.LayuiPageInfo;
import com.ruanyun.modular.admin.entity.TMonitoringinfo;
import com.ruanyun.modular.admin.entity.TMonitoringinfos;
import com.ruanyun.modular.admin.model.params.TMonitoringinfoParam;
import com.ruanyun.modular.admin.model.result.TMonitoringinfoResult;
import com.ruanyun.modular.admin.service.TMonitoringinfoService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;


/**
 * 监测信息控制器
 *
 * @author zs
 * @Date 2021-04-19 10:05:35
 */
@Controller
@RequestMapping("/tMonitoringinfo")
public class TMonitoringinfoController extends BaseController {

    private String PREFIX = "/tMonitoringinfo";

    @Autowired
    private TMonitoringinfoService tMonitoringinfoService;

    /**
     * 跳转到主页面
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/tMonitoringinfo.html";
    }

    /**
     * 新增页面
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/tMonitoringinfo_add.html";
    }

    /**
     * 编辑页面
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/tMonitoringinfo_edit.html";
    }

    /**
     * 新增接口
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(TMonitoringinfoParam tMonitoringinfoParam) {
        return this.tMonitoringinfoService.add(tMonitoringinfoParam);
    }

    /**
     * 编辑接口
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(TMonitoringinfoParam tMonitoringinfoParam) {
        return this.tMonitoringinfoService.update(tMonitoringinfoParam);
    }

    /**
     * 删除接口
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(TMonitoringinfoParam tMonitoringinfoParam) {
        return this.tMonitoringinfoService.updateDelFlagById((long)tMonitoringinfoParam.getId());
    }

    /**
     * 查看详情接口
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(TMonitoringinfoParam tMonitoringinfoParam)  {
        TMonitoringinfoResult detail = this.tMonitoringinfoService.getDetail(tMonitoringinfoParam.getId());

        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zs
     * @Date 2021-04-19
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(TMonitoringinfoParam tMonitoringinfoParam) {
        return this.tMonitoringinfoService.findPageBySpec(tMonitoringinfoParam);
    }

    /**
     * 启用
     *
     * @author zs
     * @Date 2021-04-19
     */
    @ResponseBody
    @RequestMapping("/enable")
    public ResponseData enable(@RequestParam Long id) {
        return this.tMonitoringinfoService.enableById(id);
    }

    /**
     * 禁用
     *
     * @author zs
     * @Date 2021-04-19
     */
    @ResponseBody
    @RequestMapping("/disable")
    public ResponseData disable(@RequestParam Long id) {
        return this.tMonitoringinfoService.disableById(id);
    }



//    /**
//     * 查询排放口信息表 第一次跳转 第一次跳转
//     *
//     * @author zs
//     * @Date 2021-04-19
//     */
//    @ResponseBody
//    @RequestMapping("/orificeList")
//    public LayuiPageInfo  sourceList(Integer redId, Integer redType) {
//        return tMonitoringinfoService.orificeList(redId,redType);
//    }


    /**
     * 编辑排放口信息页面
     *
     * @author zs
     * @Date 2021-05-11
     */
    @RequestMapping("/orificeList")
    public String sourceEdit() {
        return PREFIX + "/tPollutantsFactor.html";
    }


    /**
     * 编辑位置信息页面
     *
     * @author zs
     * @Date 2021-05-11
     */
    @RequestMapping("/positionEdit")
    public String positionEdit() {
        return PREFIX + "/positionEdit.html";
    }

}


